import 'package:flutter/material.dart';
import '/utils/setting.dart';
import '/utils/load_image.dart';

// 好友列表，每一项的组件
class FriendItem extends StatelessWidget {
  final String title; // 名称
  final String imgUrl; // 头像
  final VoidCallback? onTap; // 点击回调
  const FriendItem({
    super.key,
    required this.title,
    required this.imgUrl,
    this.onTap,
  });

  @override
  Widget build(BuildContext context) {

    double avatarSize = 40.0; // 头像大小

    return InkWell(
      onTap: onTap,
      child: Padding(
        padding: const EdgeInsets.fromLTRB(8, 8, 8, 0),
        child: Column(
          mainAxisAlignment: MainAxisAlignment.start,
          children: [
            Row(
              crossAxisAlignment: CrossAxisAlignment.center,
              children: [
                ClipRRect(
                  borderRadius: BorderRadius.circular(8.0),
                  child: loadImageByUrl(imgUrl, avatarSize, avatarSize)
                ),
                const SizedBox(width: 10),
                Expanded(child: Text(title)),
              ],
            ),
            const SizedBox(height: 5),
            const Divider(
              thickness: 1.0,
              indent: 50,
              endIndent: 4,
              color: DefaultColor.primary,
              height: 0,
            ),
          ],
        ),
      ),
    );
  }
}
